package top.i51213.shortcutaction;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.RecyclerView;

import java.lang.ref.WeakReference;

public class ViewPagerAdapter extends RecyclerView.Adapter<ViewPagerAdapter.HorizontalVpViewHolder> {
    static class HorizontalVpViewHolder extends RecyclerView.ViewHolder {
        public AppCompatTextView textView;
        public GridView gridView;
        public HorizontalVpViewHolder(@NonNull View itemView) {
            super(itemView);
            gridView=(GridView)(itemView.findViewById(R.id.gv));
            textView=(AppCompatTextView) (itemView.findViewById(R.id.tv));
        }
    }

    private final WeakReference<Context> context;

    public ViewPagerAdapter(Context context) {
        this.context = new WeakReference<>(context);
    }

    @NonNull
    @Override
    public ViewPagerAdapter.HorizontalVpViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new HorizontalVpViewHolder(
                LayoutInflater.from(context.get()).inflate(R.layout.item_h_v, //
                        parent,//
                        false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewPagerAdapter.HorizontalVpViewHolder holder, int position) {
        holder.textView.setText("This is "+position);
    }

    @Override
    public int getItemCount() {
        return 5;
    }
}
